<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>修改二维码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
</head>

<body>
  <div style="margin: 15px;">
    <blockquote class="layui-elem-quote">
      <div class="layui-box layui-upload-button">
        <form target="layui-upload-iframe" method="post" key="set-mine" enctype="multipart/form-data" action="">
          <input type="file" name="image" id="upFile" class="layui-upload-file">
        </form>
        <span class="layui-upload-icon">
          <i class="layui-icon"></i>修改图片</span>
      </div>
    </blockquote>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
      <legend>微信咨询二维码</legend>
    </fieldset>

    <div class="layui-form-item" style="text-align:center;">
      <img  id="codeImg" src=""/>
    </div>
  </div>

  <!--模板-->
  <script type="text/javascript" src="/admin/plugins/layui/layui.js"></script>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/ajaxfileupload.js"></script>
  <script type="text/javascript" src="js/template.js"></script>
  <script type="text/javascript" src="admin/js/publish.js"></script>
  <script>

    $.ajax({
      url:"/admin/wechat/get",
      dataType:"json",
      success:function(res){
        document.getElementById("codeImg").setAttribute("src",res.result);
      }
    });

    document.getElementById("upFile").addEventListener("change", function(event) {
      $.ajaxFileUpload({
        url: '/admin/wechat/save',
        secureuri: false,
        fileElementId: 'upFile',
        dataType: 'json',
        success: function(data, status) {
          //location.reload();
        },
        error: function(data, status, e) {
          console.log("error");
          //location.reload();
        }
      });
    });


  </script>
</body>

</html>
